
const BASE_URl = "http://192.168.6.215:8001/api/";
const BIG_NO = 99999999999;
$.ajaxSettings.beforeSend = function(xhr,request){
    xhr.setRequestHeader('Authorization','3423C4B916CCBC03AEC427B0C3D8276B211940871');
    xhr.setRequestHeader('READING','API');
};

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    var q = window.location.pathname.substr(1).match(reg_rewrite);
    if(r != null){
        return unescape(r[2]);
    }else if(q != null){
        return unescape(q[2]);
    }else{
        return null;
    }
}

function Toast(msg) {
    // zeng jia fu yuan su
    var toastElement = document.createElement("div");
    toastElement.setAttribute("id", "toast");
    toastElement.innerHTML = msg;
    document.body.appendChild(toastElement);
    toastElement.style.position = 'fixed';
    toastElement.style.top = '50%';
    toastElement.style.left = '50%';
    toastElement.style.transform = 'translate(-50%, -50%)';
    toastElement.style.background = 'rgba(0,0,0,0.6)';
    toastElement.style.borderRadius = '6px';
    toastElement.style.color = '#ffffff';
    toastElement.style.fontSize = '13px';
    toastElement.style.padding = '5px 10px 8px 10px';
    toastElement.style.zIndex = '999';
    setTimeout(function () {
        var el = document.getElementById("toast");
        document.body.removeChild(el);
    },1000);
}

function FormatDate(time){
    var date = new Date(time);

    var year = date.getFullYear(),
        month = date.getMonth()+1,//月份是从0开始的
        day = date.getDate(),
        hour = date.getHours(),
        min = date.getMinutes(),
        sec = date.getSeconds();
    var newTime = year + '-' +
        (month < 10? '0' + month : month) + '-' +
        (day < 10? '0' + day : day) + ' ' +
        (hour < 10? '0' + hour : hour) + ':' +
        (min < 10? '0' + min : min) + ':' +
        (sec < 10? '0' + sec : sec);

    return newTime;
}

